<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<form action="{:U('Shop/createShop')}" id="form" enctype="multipart/form-data" method="post">
    <input type="text" name="license_img" value="">
    店铺名称：<input type="text" name="shop_name"><br/>
    公司名称：<input type="text" name="company"><br/>
    店主：<input type="text" name="keeper"><br/>
    密码：<input type="text" name="password"><br/>
    店主手机号码：<input type="text" name="phone"><br/>
    门店电话：<input type="text" name="tel"><br/>
    店铺地址：<input type="text" name="address"><br/>
    银行卡号：<input type="text" name="bank_no"><br/>
    银行卡号所有人：<input type="text" name="bank_user_name"><br/>
    营业执照图片：<div style="width: 100px;height:100px;background: #ccc;" id="cli"></div><br/>
    <img class="img" style="width: 100px;height: 100px;"><br/>
    <input type="file" style="display: none;" id="file">
    开店说明：<input type="text" name="create_desc">
</form>
<button id="btn">提交</button>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/layer/2.4/layer.js"></script>
<script src="https://cdn.bootcss.com/jquery.form/3.19/jquery.form.js"></script>
<script type="text/javascript">
    $(function() {

        //上传营业执照
        $('#cli').click(function() {
            $('#file').click();
        });


        //营业执照预览并ajax上传
        $('#file').change(function() {
            var file = $('#file').get(0).files[0];
            var size = file.size;
            var fileSize = Math.round(size/1024*100)/100;
            if (fileSize > 5024) {
                layer.msg('营业执照图片不得超过5024KB!', {icon: 2, time: 1000});
                return false;
            }
            var reader = new FileReader();
            reader.readAsDataURL(file);
            reader.onload=function(e){
                $('.img').attr('src', e.target.result);
                $('input[name="license_img"]').val(e.target.result);
            }
        });


        //提交店铺申请
        $('#btn').click(function() {

            $('#form').submit();
/*            $('#form').ajaxSubmit({
                url: "{:U('Shop/createShop')}",
                type: "post",
                data: {
                    shop_name: $('#shop_name').val(),
                    company: $('#company').val(),
                    keeper: $('#keeper').val(),
                    password: $('#password').val(),
                    phone: $('#phone').val(),
                    tel: $('#tel').val(),
                    address: $('#address').val(),
                    bank_no: $('#bank_no').val(),
                    bank_user_name: $('#bank_user_name').val(),
                    create_desc: $('#create_desc').val(),
                    license_img: $('.img').attr('src'),

                },
                beforeSend: function() {
                    layer.msg('提交中..', {time:500});
                },
                success: function(msg) {
                    if (msg == 1) {
                        layer.msg('提交成功,请等待审核!', {time:1000});
                    } else {
                        layer.msg(msg,{icon:2});
                    }
                }
            });*/
        });
    });
</script>
